//DISCLAIMER: current status - incomplete. Indentation and displaying parts are on the line, input, output and methods optimization will be added afterwards, sorry for inconvenience

package module1.petrashenko.kpi_java_training.ua;

import java.util.*;

public class Division 
{
	private List<String> divisionProcess = new ArrayList<String>();
	private String result = "";
	
	public static void main( String[] args )
	{
		Division divisionObject = new Division();
		
		divisionObject.drawDivision( 192, 2 );
	}
	
	void drawDivision( Integer divident, Integer divisor )
	{
		String dividentString = divident.toString();
		Integer fraction = 0;
		Integer tempResult = 0;
		int step = 1;
		
		while( true )
		{
			fraction = Integer.valueOf( dividentString.substring(0, step));
			final int FRACTION_LENGTH = (fraction.toString()).length();
			step = 1;
			
			if( fraction < divisor )
			{
				step++;
				continue;
			}
			
			tempResult = fraction / divisor;
			result += tempResult;
			divisionProcess.add( Integer.toString( tempResult * divisor ) );
			
			if( Integer.valueOf( result ) == divident / divisor )
			{
				break;
			}
			
			if( fraction % divisor != 0 )
			{	
				
				String part1 = Integer.toString( fraction % divisor );
				String part2 = dividentString.substring( FRACTION_LENGTH, FRACTION_LENGTH + step );
				
				dividentString = part1 + part2; 
			}
			else
			{
				dividentString = dividentString.substring( FRACTION_LENGTH, FRACTION_LENGTH + step );
			}
		}
	}
	
}
